# 先定义一个函数

# def test():
#     print('hello')
#     print('hello')
#     print('hello')
#
# # 然后再调用
# test()


# def test(a,b,c):
#     print(a,b,c)
#
# test(10,20,44)
# test(10,'hello',True)

# def add(x,y):
#     return x+y
# print(add(3,5))
# print(add(3.5,5.8))
# print(add('hello','world'))

# 练习:求beg到end范围内的整数之和

# def sum(beg,end):
#     sum=0
#     for i in range(beg,end+1):
#         sum+=i
#     print(sum)
#
# sum(1,100)
# sum(345,872)

# def sum(beg,end):
#     sum=0
#     for i in range(beg,end+1):
#         sum+=i
#     return sum
#
# result=sum(1,100)
# print(result)

# def isodd(num):
#     if num%2==0:
#         return True
#     else:
#         return False
#
# print(isodd(11))
# print(isodd(100))


# 写一个函数,返回平面上的一个点

# def getpoint():
#     x=10
#     y=20
#     return x,y
#
# a,b=getpoint()
# print(a,b)

# x=10
# def test():
#     x=20
#     print(f'函数内部{x}')
# test()
# print(f'函数外部{x}')


# 如何在函数内部修改全局变量

# x=10
#
# def test():
#     global x
#     x=20
# test()
# print(f'x的值为{x}')

# for i in range(1,11):
#     print(f'函数内部i的值为{i}')
# print('------------')
# print(f'函数外部i的值为{i}')

# def test():
#     print('执行函数内部代码')
#     print('执行函数内部代码')
#     print('执行函数内部代码')
#     print('执行函数内部代码')
# print('11111')
# test()
# print('22222')
# test()
# print('33333')
# test()
# print('44444')


# def isodd(num):
#     if num%2==0:
#         return False
#     return True
#
# def add(x,y):
#     return x+y
#
# # print(isodd(100))
# # print(isodd(99))
#
# print(isodd(add(12,34)))
# print(isodd(add(22,33)))


# 嵌套调用

# def a():
#     print('函数a')
# def b():
#     a()
#     print('函数b')
#
# def c():
#     b()
#     print('函数c')
#
# def d():
#     c()
#     print('函数d')
#
#
# d()

# for i in range(1, 10):
#     print(f'函数内部 i = {i}')
# print(f'函数外部 i = {i}')

# 写一个函数,求n!(n为正整数)

def fact(n):
    k=1
    for i in range(1,n+1):
      k*=i
    return k
print(fact(5))